package org.academic.texteditor.gui.component.menu;

import java.util.HashMap;
import java.util.Map;

import javax.swing.JMenu;
import javax.swing.JMenuBar;

public class MenuManager {

	private static MenuManager instance;
	private JMenuBar menuBar;
	private Map<String, JMenu> menus;
	
	private MenuManager() {
		menus = new HashMap<String, JMenu>();
	}
	
	public static synchronized MenuManager getInstance() {
		if (instance == null) {
			instance = new MenuManager();
		}
		return instance;
	}
	
	public void addMenu(JMenu menu) {
		menus.put(menu.getName(), menu);
	}
	
	public JMenu getMenu(String name) {
		return menus.get(name);
	}

	public JMenuBar getMenuBar() {
		return menuBar;
	}

	public void setMenuBar(JMenuBar menuBar) {
		this.menuBar = menuBar;
	}
	
}
